package com.jiayinlending.jiayindai.activity.myrepay;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.jiayinlending.jiayindai.R;
import com.jiayinlending.jiayindai.activity.base.BaseActivity;
import com.jiayinlending.jiayindai.fragment.adapter.CouponAdpater;
import com.jiayinlending.jiayindai.fragment.myrepay.CouponFragment;
import com.jiayinlending.jiayindai.fragment.myrepay.RedFragment;

import java.util.ArrayList;

public class CouponActivity extends BaseActivity {
    private ArrayList<String> titleList = new ArrayList<String>() {{
        add("红包");
        add("抵用券");
    }};

    private ArrayList<Fragment> fragmentList = new ArrayList<Fragment>() {{
        add(new RedFragment());
        add(new CouponFragment());
    }};

    private TabLayout tlMain;
    private ViewPager vpMain;

    private CouponAdpater adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
        getToolbarTitle().setText("卡包");
        getSubTitle().setText("");
        adapter = new CouponAdpater(getSupportFragmentManager(), titleList, fragmentList);
        vpMain.setAdapter(adapter);
        tlMain.setupWithViewPager(vpMain);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_coupon;
    }

    private void initView() {
        tlMain = (TabLayout) findViewById(R.id.tlMain);
        vpMain = (ViewPager) findViewById(R.id.vpMain);
    }

}
